//
//  NavigationController.swift
//  myhub
//
//  Created by x on 2024/5/27.
//

import UIKit
import XDesignKit
import XResources

open class NavigationController: UINavigationController {
    open override var preferredStatusBarStyle: UIStatusBarStyle {
        return globalStatusBarStyle.value
    }

    open override func viewDidLoad() {
        super.viewDidLoad()
        // 仅用iOS 自带返回手势
        interactivePopGestureRecognizer?.delegate = nil

        if #available(iOS 13.0, *) {
            hero.isEnabled = false
        } else {
            hero.isEnabled = true
        }
        hero.modalAnimationType = .autoReverse(presenting: .fade)
        hero.navigationAnimationType = .autoReverse(presenting: .slide(direction: .left))

        // navigationBar.isTranslucent = false
        navigationBar.backIndicatorImage = R.image.arrowBackOutline()
        navigationBar.backIndicatorTransitionMaskImage = R.image.arrowBackOutline()

        navigationBar.theme.tintColor = themeService.attribute { $0.secondary }
//      navigationBar.theme.barTintColor = themeService.attribute { $0.primaryDark }
        navigationBar.theme.titleTextAttributes = themeService.attribute { [NSAttributedString.Key.foregroundColor: $0.text] }
    }
}
